/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
  vector<int> reversePrint(ListNode* head) {

    vector<int> ans;

    dfs(head, ans);

    return ans;

  }

  void dfs(ListNode *node, vector<int> &ans){

    if(node == nullptr){
      return;
    }

    dfs(node->next, ans);

    ans.emplace_back(node->val);

  }
};